How can I add \n(newline) In Json string |
您所在的位置:网站首页 › python unicode type to string › How can I add \n(newline) In Json string |
![]() Did you try it with double \n e.g., data = '{JsonString}\\n' This sequence produces two characters at the end of the string \ and n. Not something expected in the NDJSON format. For NDJSON there should be the LF character: '\n' or the CR LF sequence should also be accepted: '\r\n'. Unfortunately we do not know what exactly has @Harsh tried. I suspect that the problem could also be in the unescaped double quotes in the JSON string values as I wrote earlier. In the Python string it should be '\\"' instead of wrong '\"'. Or problem could be the spaces shown above if they are really present in the HTTP payload. The comparison of the network communication captures can resolve the problem easily if done properly. ![]() FYI I am already using -X in tcp command. The output of tcpdump with the option -X looks like below. Hexadecimal values of the captured bytes are important when we cannot distinguish them by their ASCII representation (like the dot). $ sudo tcpdump -nXc1 host 8.8.8.8 2>/dev/null & sleep 0.1 ; ping -c1 -p"$(xxd -pu |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |